﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - WebView</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
    @RenderBody()
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @RenderSection("Scripts", required: false)

    <script type="text/javascript">
        $(() => {
            $("span[class='code_chunk_copy']").each(function (index, domelement) {
                $(this).click(function () {
                    copyCode(this);
                });
            })
        });

        //复制代码
        function copyCode(obj) {
            let thisObj = $(obj);
            let parent = thisObj.parent().parent();
            let is_copy = parent.attr("is_copy");
            if (is_copy == "1") {
                parent.attr("is_copy", "0");
                thisObj.text("复制代码");                
            } else {
                parent.attr("is_copy", "1");
                thisObj.text("取消复制");
            }
            is_copy = parent.attr("is_copy");
            parent.children().each(function (index, domelement) {
                let child = $(this);
                let tagName = child[0].tagName;
                if (tagName.toLowerCase() == "div") {
                    let iclass = child.attr("class");
                    if (iclass == "code_show") {
                        if (is_copy == "0") {
                            child.css("display", "");
                        } else {
                            child.css("display", "none");
                        }

                    } else if (iclass == "code_text") {
                        if (is_copy == "0") {
                            child.css("display", "none");
                        } else {
                            child.css("display", "");
                        }
                    }
                }
            })
        }
    </script>
</body>
</html>
